package com.homedo.odin.solution.enumcode.brand;

import java.util.Arrays;
import lombok.Getter;

@Getter
public enum FirmStatusEnum {

    AUDITING(10, "审核中"),
    AUDITPASS(20, "审核通过"),
    AUDITREJECTED(21, "审核驳回");

    private Integer dbValue;
    private String displayValue;

    FirmStatusEnum(Integer dbValue, String displayValue) {
        this.dbValue = dbValue;
        this.displayValue = displayValue;
    }

    /**
     * 判断是否存在枚举dbValue
     */
    public static boolean dbValueExist(Integer dbValue) {
        return Arrays.stream(FirmStatusEnum.values()).anyMatch(obj -> obj.getDbValue().equals(dbValue));
    }

    /**
     * 判断是否存在枚举displayValue
     */
    public static boolean displayValueExist(String displayValue) {
        return Arrays.stream(FirmStatusEnum.values()).anyMatch(obj -> obj.getDisplayValue().equals(displayValue));
    }


    /**
     * 匹配获取对应的DisplayValue
     */
    public static String getExistDisplayValue(Integer dbValue) {
        return Arrays.stream(FirmStatusEnum.values()).filter(obj -> obj.getDbValue().equals(dbValue))
                .map(obj -> obj.getDisplayValue()).findFirst().orElse(null);
    }
}
